<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript"
	src="${ctx}/scripts/validation/validation.js"></script>

<link href="${ctx}/scripts/jscalendar-1.0/calendar-blue2.css"
	rel="stylesheet" type="text/css">
<script language="JavaScript"
	src="${ctx}/scripts/jscalendar-1.0/calendar.js"></script>
<script language="JavaScript"
	src="${ctx}/scripts/jscalendar-1.0/lang/calendar-en.js"></script>
<script language="JavaScript"
	src="${ctx}/scripts/jscalendar-1.0/calendar-setup.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript">
	var ACTION_URL = "${ctx}/charge_parameterDefAction.do?";
	var sourceValue;

	//修改
	function edit(){
		var url= ACTION_URL + "method=edit";
		var pars=$('fparameterDef').serialize();
		//校验
		var isTure= $("fparameterDef").fireEvent("onSubmit");
		//ajax提交
		if(isTure){
			closeORopenButton();
		//			alert(url);
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: showResponseEdit}
		                    );
		}
	}

	//修改操作的响应
	function showResponseEdit(result){
		var obj=findFrame('main');
		obj.reLoadIFrameListWithQuery();
		closeORopenButton();
		ajaxSubmitException(result.responseText);
		windowClose();
	}

	function init(){
		sourceValue=$('fparameterDef').serialize();
		if('${parameterDefVO.pvalue}'!=''){
			$('btn1_22').disabled=true;
			$('a_select').href="#";
		}
	}


	//如果内容有修改，则先提示是否关闭
	function closeWin(){
		var newValue=$('fparameterDef').serialize();
		if(sourceValue==newValue){
			windowClose();
		}else{
			AskConfirmTwo('${key.tipsForCloseWindow}',"editPageIframe","afterCloseDo","windowClose");
		}
	}

	//关闭窗口前执行的动作
	function afterCloseDo(){
		edit();
	}

	//关闭或打开按钮事件
	function closeORopenButton(){
		$$('#window_footer').disabled= !$$('#window_footer').disabled;
		$('btn1_22').disabled= !$('btn1_22').disabled;
		$('btn1_32').disabled= !$('btn1_32').disabled;
	}

	function openSelectbusinessCode(){
		var url="${ctx}/charge_businessCodeAction.do?" + "method=initSelectBusinessCode&iframeName=editPageIframe";
		top.windowOpen(url, 'selectBusinessCode', '${key.add}', 400, 400, true, "selectBusinessCodeIframe");
	}

	function selectBusinessCodeInfo(id,code){
		$('pvalue').value = id;
		$('pvalueView').value = code;
	}

	function openSelectChargeItem(){
		var url=ACTION_URL + "method=initSelectChargeItem&iframeName=editPageIframe";
		top.windowOpen(url, 'selectBusinessCode', '${key.add}', 400, 400, true, "initSelectChargeItemIframe");
	}
</script>

</head>

<body onload="init();">
<form action="javascript:edit()" name="fparameterDef" class="required-validate" method="post">
<input type="hidden" name="parameterDefId" value="${parameterDefVO.parameterDefId}">
<input type="hidden" name="pvalue" value="${parameterDefVO.pvalue}">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"><span class="window_head_intext">修改</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color"><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">

          <tr>
            <td class="aux_intable_td1">${key.pname}：</td>
            <td class="aux_intable_td2"><span class="grid align_left">${parameterDefVO.pname}</span></td>
          </tr>
          <tr>
            <td class="aux_intable_td1">
            <c:choose>
            	<c:when test="${parameterDefVO.isPayBusinessCode || parameterDefVO.isRevenueBusinessCode}">
            		${key.bizCode}：
            	</c:when>
            </c:choose>
            </td>
            <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><input id="pvalueView" type="text" class="inputtext required" value="${parameterDefVO.pvalueView}" READONLY   size="16"></td>
                <td width="4">&nbsp;</td>
                <td>
	            <c:choose>
	            	<c:when test="${parameterDefVO.isPayBusinessCode || parameterDefVO.isRevenueBusinessCode}">
	            		<a id="a_select" href="javascript:openSelectbusinessCode();"  onFocus="this.blur()">
	            	</c:when>
	            	<c:when test="${false}">
	            		<a id="a_select" href="javascript:openSelectChargeItem();"  onFocus="this.blur()">
	            	</c:when>
	            </c:choose>
                <img src="${ctx}/images/ico_cz.gif" width="16" height="16" border="0" ></a></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td valign="top" class="aux_intable_td1">${key.description}：</td>
            <td class="aux_intable_td2"><span class="grid align_left">${parameterDefVO.description }</span></td>
              </tr>

        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
        <td class="btn_between_space">&nbsp;</td>
        <td><table border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td class="buttonOffLeft" id="btn1_21"></td>
     <td class="buttonOffMiddle" id="btn1_22" onClick="edit();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.save}</td>
                <td class="buttonOffRight" id="btn1_23"></td>
              </tr>
          </table></td>
          <td class="btn_between_space"></td>
          <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
                <td class="buttonOffMiddle" id="btn1_32" onClick="closeWin();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.close}</td>
                <td class="buttonOffRight" id="btn1_33"></td>
              </tr>
          </table></td>
        </tr>
    </table>
    <p>&nbsp;</p></td>
  </tr>
</table>
</form>
</body>
</html>